<template>
  <div id="layout">
    <div class="top-bar-warpper">
      <div class="top-bar">
        <img class="top-bar-logo" src="@/assets/images/logo.jpg" alt />
        <div class="top-bar-project">
          <div class="project-item" @click="scrollTo(1)">
            <span>延保</span>
            <i>Extended Warranty</i>
          </div>
          <div class="project-item" @click="scrollTo(2)">
            <span>房延保</span>
            <i>House Extended Warranty</i>
          </div>
          <div class="project-item" @click="scrollTo(3)">
            <span>关于我们</span>
            <i>About us</i>
          </div>
          <div class="project-item" @click="scrollTo(4)">
            <span>联系我们</span>
            <i>Contact us</i>
          </div>
        </div>
        <div class="top-bar-more">
          <img src="@/assets/images/header-chat.png" width="25" alt="" />
          <span>在线留言</span>
          <i>|</i>
          <span>中/En</span>
        </div>
      </div>
    </div>
    <a-carousel class="carousel" arrows>
      <div slot="prevArrow">
        <a-icon type="left-circle" />
      </div>
      <div slot="nextArrow">
        <a-icon type="right-circle" />
      </div>
      <div class="carousel-item" v-for="(e, i) in 1" :key="i">
        <img :src="`/public/images/carousel-${i + 1}.png`" alt />
      </div>
    </a-carousel>
    <div class="content-warpper clearfix">
      <div class="content">
        <about-extended-warranty id="part1"></about-extended-warranty>
        <house-extended-warranty id="part2"></house-extended-warranty>
        <about-us id="part3"></about-us>
        <contact-us id="part4"></contact-us>
      </div>
    </div>
    <footer>
      <img src="@/assets/images/logo.png" alt="" style="height: 52px; margin-bottom: 15px" />
      <p>中延相伴 &nbsp;&nbsp;&nbsp;&nbsp; 安居无忧</p>
      <div class="footer-imgs">
        <div><img src="@/assets/images/footer-1.png" alt="" /></div>
        <div><img src="@/assets/images/footer-2.png" alt="" /></div>
        <div><img src="@/assets/images/footer-3.png" alt="" /></div>
      </div>
      <div class="footer-copyright">
        <p>版权所有©2016江苏中延房屋维护技术服务股份有限公司 <span @click="jumpPolice">公安备案号32010602010456</span></p>
        <p>官网ICP备案号：<span @click="jumpIpc">苏ICP备18014342号-1</span></p>
      </div>
    </footer>
    <div class="back" @click="scrollTo(0)" v-if="scrollTop > 2000">
      <a-icon type="caret-up" class="icon" />
    </div>
  </div>
</template>

<script>
const AboutExtendedWarranty = () =>
  import("./components/AboutExtendedWarranty");
const HouseExtendedWarranty = () =>
  import("./components/HouseExtendedWarranty");
const AboutUs = () => import("./components/AboutUs");
const ContactUs = () => import("./components/ContactUs");
export default {
  name: "Home",
  components: {
    AboutExtendedWarranty,
    HouseExtendedWarranty,
    AboutUs,
    ContactUs
  },
  data() {
    return {
      scrollTop: ""
    };
  },
  mounted() {
    let _this = this;
    window.addEventListener("scroll", () => {
      let scrollTop =
        document.body.scrollTop || document.documentElement.scrollTop;
      _this.scrollTop = scrollTop;
    });
  },
  methods: {
    jumpPolice() {
      window.open(
        "http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=32010602010456"
      );
    },
    jumpIpc() {
      window.open("https://beian.miit.gov.cn/#/Integrated/index");
    },
    scrollTo(key) {
      switch (key) {
        case 0:
          window.scrollTo({
            top: 0,
            behavior: "smooth"
          });
          break;
        case 1:
          window.scrollTo({
            top: 500,
            behavior: "smooth"
          });
          break;
        case 2:
          window.scrollTo({
            top: 1750,
            behavior: "smooth"
          });
          break;
        case 3:
          window.scrollTo({
            top: 4200,
            behavior: "smooth"
          });
          break;
        case 4:
          window.scrollTo({
            top: 6600,
            behavior: "smooth"
          });
          break;
      }
    }
  }
};
</script>

<style lang='less' scoped>
@baseBg: #0e0a64;
@base: #00a0e9;
#layout {
  .back {
    position: fixed;
    right: 10px;
    bottom: 10px;
    width: 40px;
    height: 40px;
    color: @baseBg;
    line-height: 35px;
    text-align: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 0 3px 0px #fff;
    z-index: 99999;
    background: #fff;
  }
  .top-bar-warpper {
    z-index: 999;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: @baseBg;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 85px;
    .top-bar {
      width: 1280px;
      height: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .top-bar-logo {
        height: 35px;
      }
      .top-bar-project {
        height: 100%;
        flex: 1;
        display: flex;
        justify-content: space-between;
        margin: 0 45px;
        .project-item {
          width: 25%;
          height: 100%;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
          cursor: pointer;
          color: #fff;
          font-size: 14px;
          transition: all 0.2s;
          &:hover {
            background-color: @base;
          }
        }
      }
      .top-bar-more {
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;
        img {
          margin-right: 10px;
        }
        span {
          cursor: pointer;
          transition: all 0.2s;
          &:hover {
            color: @base;
          }
        }
        i {
          margin: 0 10px;
        }
      }
    }
  }
  .carousel {
    width: 100%;
    height: 600px;
    margin-top: 85px;
    overflow: hidden;
    .carousel-item {
      height: 600px;
      img {
        width: 100%;
        height: 600px;
      }
    }
  }
  .content-warpper {
    position: relative;
    width: 100%;
    background: #e5e5e5;
    &::after {
      content: "";
      display: block;
      clear: both;
    }
    .content {
      background: #fff;
      width: 1280px;
      position: relative;
      top: -60px;
      left: 50%;
      transform: translateX(-50%);
      padding: 0 60px 60px;
      display: inline-block;
    }
  }
  footer {
    background: @baseBg;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    p {
      color: #fff;
      font-size: 16px;
    }
    .footer-imgs {
      width: 300px;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      div {
        width: 45px;
        height: 45px;
        border-radius: 50%;
        overflow: hidden;
      }
    }
    .footer-copyright {
      text-align: center;
      margin: 36px 0 0 0;
      p {
        margin: 0;
        font-size: 14px;
        color: #e4e4e4;
        &:nth-child(1) {
          margin-bottom: 8px;
          position: relative;
          &::before {
            content: "";
            display: inline-block;
            width: 20px;
            height: 20px;
            background: url("~@/assets/images/police.png") 0 0 no-repeat;
            position: absolute;
            right: -30px;
            top: 50%;
            transform: translateY(-50%);
          }
        }
        span {
          text-decoration: underline;
          cursor: pointer;
          transition: all 0.2s;
          &:hover {
            color: @base;
          }
        }
      }
    }
  }
}
</style>
